angular.module('app.controllers', [])

    .controller('homeCtrl', function ($scope, $state) {
        $scope.headImg = 'img/ben.png'
        $scope.readMe = function () {
            $state.go('readMe')
        }
    })
    .controller('welComeCtrl', function ($scope, $timeout, $state) {
        $timeout(function () {
            $state.go('login');
        }, 1000);
    })
    .controller('loginCtrl', function ($scope, $state) {
        $scope.login = function () {
            $state.go('tabs.home');
        }
    })
    .controller('zhuceCtrl', function ($scope, $state) {
        $scope.zhuce = function () {
            $state.go('tabs.home');
        }
    })
    .controller('jiaoyiCtrl', function ($scope, $state) {
        $scope.showDaPan = function () {
            $state.go('wyjiaoyi');
        }
    })
    .controller('wyjiaoyiCtrl', function ($scope, $state) {
        $scope.quDingJaoYi = function () {
            $state.go('jiaoYiSuccess');
        }
    })
    //-----------培训报名 start---------------------//
    .controller('pxbmCtrl', function ($scope, $state) {
        $scope.baoMing = function () {
            $state.go('touZiPeiXunDetail');
        }
    })
    .controller('touZiPeiXunDetailCtrl', function ($scope, $state) {
        $scope.confirmBm = function () {
            $state.go('pay');
        }
    })

    //-----------培训报名 end---------------------//
    .controller('payCtrl', function ($scope, $state) {
        $scope.confirmPay = function () {
            $state.go('tabs.pxbm');
        }
    })
    //-----------个人信息 start---------------------//
    .controller('personCtrl', function ($scope, $state) {
        $scope.chongZhi = function () {
            $state.go('chongZhi');
        };
        $scope.tiXian = function () {
            $state.go('tiXian');
        }
    })
    .controller('chongZhiCtrl', function ($scope, $state) {

    })
    .controller('xiuGaiZiLiaoCtrl', function ($scope, $state, $ionicPopup,$ionicActionSheet) {
        $scope.editName = function () {
            $scope.data = {}
            // An elaborate, custom popup
            var myPopup = $ionicPopup.show({
                template: '<input type="text">',
                title: '修改昵称',
                //subTitle: 'Please use normal things',
                scope: $scope,
                buttons: [
                    {text: '取消'},
                    {
                        text: '<b>保存</b>',
                        type: 'button-positive',
                        onTap: function (e) {
                            if (!$scope.data.wifi) {
                                //don't allow the user to close unless he enters wifi password
                                // e.preventDefault();
                            } else {
                                return $scope.data.wifi;
                            }
                        }
                    },
                ]
            });
            myPopup.then(function (res) {
                console.log('Tapped!', res);
            });

        };

        $scope.editHeadImg = function () {
            $ionicActionSheet.show({
                buttons: [
                    {text: '拍照'},
                    {text: '从手机相册选择'},
                ],
                cancelText: '取消',
                buttonClicked: function (index) {
                    return true;
                }
            });
        };

        $scope.editSex = function(){
            $ionicActionSheet.show({
                buttons: [
                    {text: '男'},
                    {text: '女'},
                    {text: '其他'},
                ],
                cancelText: '取消',
                buttonClicked: function (index) {
                    return true;
                }
            });
        };

        $scope.editAge = function () {
            $scope.data = {}
            // An elaborate, custom popup
            var myPopup = $ionicPopup.show({
                template: '<input type="text">',
                title: '修改年龄',
                //subTitle: 'Please use normal things',
                scope: $scope,
                buttons: [
                    {text: '取消'},
                    {
                        text: '<b>保存</b>',
                        type: 'button-positive',
                        onTap: function (e) {
                            if (!$scope.data.wifi) {
                                //don't allow the user to close unless he enters wifi password
                                // e.preventDefault();
                            } else {
                                return $scope.data.wifi;
                            }
                        }
                    },
                ]
            });
            myPopup.then(function (res) {
                console.log('Tapped!', res);
            });

        };


    })


//-----------个人信息 end---------------------//

